package com.lp.biz.operations.model.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.lp.biz.content.model.entity.BizCoreContent;
import lombok.Data;

import java.time.LocalDate;
import java.time.LocalDateTime;

import static com.lp.common.constant.CommonConstant.*;

/**
 * @program: backend
 * @description:
 * @author: Ke.Song
 * @since: 2024-07-18 23:46:18
 */
@Data
public class CategoryList {

    private Integer id;

    private String bizCategoryCode;

    private String title;

    private Integer isDisplay;

    @JsonFormat(timezone = TIMEZONE, pattern = DATE)
    private LocalDate startAt;

    @JsonFormat(timezone = TIMEZONE, pattern = DATE)
    private LocalDate endAt;

    @JsonFormat(timezone = TIMEZONE, pattern = DATE_TIME)
    private LocalDateTime createAt;

    public static CategoryList builder(BizCoreContent content) {
        CategoryList categoryList = new CategoryList();
        categoryList.setId(content.getId());
        categoryList.setBizCategoryCode(content.getBizCategoryCode());
        categoryList.setTitle(content.getTitle());
        categoryList.setIsDisplay(content.getIsDisplay());
        categoryList.setStartAt(content.getRecommendStartAt());
        categoryList.setEndAt(content.getRecommendEndAt());
        categoryList.setCreateAt(content.getCreateAt());
        return categoryList;
    }
}
